"""
@author RansySun
@create 2019-12-02-21:46
"""
from rest_framework.throttling import SimpleRateThrottle


class SMSRateThrottle(SimpleRateThrottle):
    """
    短信刷新频率
    """
    scope = "sms"

    def get_cache_key(self, request, view):
        mobile = request.data.get("mobile")
        if mobile:
            return f"sms_throttle_{mobile}"
